#!/bin/bash

if [[ $# -le 0 ]]
then
	echo must supply unique session id
	exit -1
fi

sessionid=$1
dirname=`dirname $0`

. ${dirname}/meta.sh

if [[ -d ${workdir} ]]
then
	if [[ -p ${pipein} ]]
	then
		fuser ${pipein} |&  awk '{for(i=2;i<=NF;i++){cmd="kill -9 "$i; system(cmd);}}'
	fi
	if [[ -p ${pipeout} ]]
	then
		fuser ${pipeout} |&  awk '{for(i=2;i<=NF;i++){cmd="kill -9 "$i; system(cmd);}}'
	fi
	if [[ -f ${vxrefout} ]]
	then
		fuser ${vxrefout} |&  awk '{for(i=2;i<=NF;i++){cmd="kill -9 "$i; system(cmd);}}'
	fi
	if [[ -f ${vxreflock} ]]
	then
		fuser ${vxreflock} |&  awk '{for(i=2;i<=NF;i++){cmd="kill -9 "$i; system(cmd);}}'
	fi
	rm -f $pipein $pipeout $vxrefout $vxreflock
  rm -f ${workdir}/*.dat
  rm -f ${workdir}/*.preload
	rmdir ${workdir}
fi
